package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.iview.PayView

/**
 * Created by Never Fear   on 2018\11\26 0026.
Never More....
 */
class PayModule :BaseModule {
    var listener:PayView?=null

    fun yearPay(c:Context,id:String,type:Int){
        Apis.yearPay(type, id)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<String>>(c){
                                override fun httpSuccess(t: Response<String>) {
                                    listener?.setYearPayOrderSign(t.body())
                                }
                            })
                }
    }

    fun violationPay(c:Context,id:String,type:Int){
        Apis.violationPay(type, id)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<String>>(c){
                                override fun httpSuccess(t: Response<String>) {
                                    listener?.setViolationPayOrderSign(t.body())
                                }
                            })
                }
    }

}